/**
 * @Author: liu.yang
 * @Date: 2018-07-19 21:58:44
 */
import React, { Component } from "react";
//  HashRouter BrowserRouter
import { HashRouter as Router, Route, Switch, Redirect } from "dva/router";
// 由于 antd 组件的默认文案是英文，所以需要修改为中文
import { connect } from "dva";
import moment from "moment";
import "moment/locale/zh-cn";
import BaseLayout from "./components/layouts/BaseLayout";
import HomePage from "./pages/home/HomePage";
import documentPage from "./pages/document";
import MonitorPush from "./pages/businessManagement/monitorPush";
import ApplicationManagement from "./pages/applicationManager/ApplicationManagement";
import DataManagement from "./pages/recommendCenter/datasource";
import dataSourceDetail from "./pages/recommendCenter/dataSourceDetail";
import AddInfo from "./pages/recommendCenter/add";
import SituationPage from "./pages/recommendCenter/situation";
import AddSituationPage from "./pages/recommendCenter/addSituation";
import PlanManage from "./pages/recommendCenter/plan";
import AddPlanPage from "./pages/recommendCenter/addPlan";
import MessagePage from "./pages/message/messageFile";
import BacklogPage from "./pages/systemManager/backlog";
import OperateLogPage from "./pages/systemManager/operateLog";
import InterfaceLog from "./pages/systemManager/interfaceLog";
import SensitiveLogPage from "./pages/systemManager/sensitiveLog";
import SceneDetailPage from "./pages/recommendCenter/sceneDetail";
import PlanDetail from "./pages/planDetail";
import MessageSource from "./pages/messageManager/messageSource";
import ChannelManager from "./pages/messageManager/channelManager";
import ChannelDetail from "./pages/messageManager/channelManager/ChannelDetail";
import LabelManager from "./pages/messageManager/labelManager";
import labelAdd from "./pages/messageManager/labelAdd";
import labelEdit from "./pages/messageManager/labelEdit";
import LabelDetail from "./pages/messageManager/labelDetail";
import MyLabelManager from "./pages/messageManager/myLabelManager";
import MyLabelAdd from "./pages/messageManager/myLabelAdd";
import MyLabelEdit from "./pages/messageManager/myLabelEdit";
import MyLabelDetail from "./pages/messageManager/myLabelDetail";

import MyMessage from "./pages/messageManager/myMessage";
import Exception from "./pages/exception/403";
import FeedbackPage from "./pages/message/feedback";
import MessageSend from "./pages/messageManager/messageSend";
import MessageAdd from "./pages/messageManager/messageAddNew";
import BackLog from "./pages/systemManager/messageCenter/backLog";
import MessageDetail from "./pages/systemManager/messageCenter/messageDetail";

import ChannelAdd from "./pages/messageManager/channelAdd";
import SupervisoryManager from "./pages/messageManager/supervisoryManager";
import SupervisoryAdd from "./pages/messageManager/supervisoryAdd";
import ChannelNumber from "./pages/messageManager/channelNumber";
import Edit from "./pages/messageManager/channelNumber/components/edit/Edit";
import ChannelRegister from "./pages/messageManager/channelRegister/index";
import UserManagement from "./pages/messageManager/personalInfoMgt/UserManagement";

import SMSquotaList from "./pages/messageManager/SMSquotaList";
import AddSMSquota from "./pages/messageManager/SMSquotaList/AddSMSquota";
import SMSquotaHistoryRecord from "./pages/messageManager/SMSquotaList/historyRecord";
import SMSstatistics from "./pages/messageManager/SMSstatistics";

import MsgSourceManage from "./pages/messageManager/msgSourceManage";
import MsgSourceDetail from "./pages/messageManager/msgSourceManage/components/detail";
import MsgSourceLogs from "./pages/messageManager/msgSourceManage/components/logs";

import TemplateManager from "./pages/messageManager/templateManager";
import AcceptGroup from "./pages/messageManager/acceptGroup";
import AddTemplate from "./pages/messageManager/templateManager/add";
import AddAcceptGroup from "./pages/messageManager/acceptGroup/add";
import ApproveDetail from "./pages/systemManager/messageCenter/backLog/approveDetail";
import TenantPage from "./pages/systemManager/tenant";
import dingdingQunPage from "./pages/dingdingQun";

moment.locale("zh-cn");
const prefix = "/intellPush"; // 智能推送路由前缀
const prefix1 = "/systemManager"; // 系统管理路由前缀
const prefix2 = "/messageCenter"; // 消息总线路由前缀

@connect(({ user }) => ({
  user
}))
class RouterConfig extends Component {
  renderRouter = () => (
    <Switch>
      <Route
        path={`/`}
        render={() => (
          <Redirect to={`${prefix2}/channelManager/channelList`} />
        )}
        exact
      />
      <Route
        path={`/messageCenter`}
        render={() => (
          <Redirect to={`${prefix2}/channelManager/channelList`} />
        )}
        exact
      />
      <Route path={`${prefix}/home`} component={HomePage} exact />
      <Route path={"/document"} component={documentPage} exact />
      <Route path={`${prefix}/exception`} component={Exception} />
      <Route
        path={`${prefix}/applicationManager`}
        component={ApplicationManagement}
        exact
      />
      <Route
        path={`${prefix}/recommendCenter/dataSource`}
        component={DataManagement}
        exact
      />
      <Route
        path={`${prefix}/recommendCenter/dataSource/dataSourceDetail`}
        component={dataSourceDetail}
        exact
      />
      <Route
        path={`${prefix}/recommendCenter/dataSource/addInfo`}
        component={AddInfo}
        exact
      />
      <Route
        path={`${prefix}/recommendCenter/dataSource/editInfo`}
        component={AddInfo}
        exact
      />
      <Route
        path={`${prefix}/recommendCenter/situation`}
        component={SituationPage}
        exact
      />
      <Route
        path={`${prefix}/recommendCenter/situation/addScene`}
        component={AddSituationPage}
        exact
      />
      <Route
        path={`${prefix}/recommendCenter/situation/editScene`}
        component={AddSituationPage}
        exact
      />
      <Route
        path={`${prefix}/recommendCenter/plan`}
        component={PlanManage}
        exact
      />
      <Route
        path={`${prefix}/recommendCenter/plan/planDetail`}
        component={PlanDetail}
        exact
      />
      <Route
        path={`${prefix}/recommendCenter/plan/addPlan`}
        component={AddPlanPage}
        exact
      />
      <Route
        path={`${prefix}/recommendCenter/plan/editPlan`}
        component={AddPlanPage}
        exact
      />
      <Route
        path={`${prefix}/messagePic/messageFile`}
        component={MessagePage}
        exact
      />
      <Route
        path={`${prefix}/messagePic/feedback`}
        component={FeedbackPage}
        exact
      />
      <Route
        path={`${prefix}/recommendCenter/situation/sceneDetail`}
        component={SceneDetailPage}
        exact
      />
      <Route
        path={`${prefix1}/systemManage/backLog/planDetail`}
        component={PlanDetail}
        exact
      />
      <Route
        path={`${prefix2}/messageManager/messageSource`}
        component={MessageSource}
        exact
      />
      <Route
        path={`${prefix2}/messageManager/messageSource/messageDetail`}
        component={MessageDetail}
        exact
      />
      <Route
        path={`${prefix2}/messageManager/messageSend`}
        component={MessageSend}
        exact
      />
      <Route
        path={`${prefix2}/messageManager/messageSource/messageAdd`}
        component={MessageAdd}
        exact
      />
      <Route
        path={`${prefix2}/messageManager/myMessage`}
        component={MyMessage}
        exact
      />
      <Route
        path={`${prefix2}/channelManager/channelList`}
        component={ChannelManager}
        exact
      />
      <Route
        path={`${prefix2}/channelManager/channelList/channelDetail`}
        component={ChannelDetail}
        exact
      />

      <Route
        path={`${prefix2}/supervisoryManager`}
        component={SupervisoryManager}
        exact
      />
      <Route
        path={`${prefix2}/supervisoryManager/supervisoryAdd`}
        component={SupervisoryAdd}
        exact
      />
      <Route
        path={`${prefix1}/systemMessage/messageBacklog/messageDetail`}
        component={MessageDetail}
        exact
      />
      <Route
        path={`${prefix1}/systemMessage/operateLog`}
        component={OperateLogPage}
        exact
      />
      <Route path={`/exception/403`} component={Exception} exact />
      <Route
        path={`${prefix}/business/MonitorPush`}
        component={MonitorPush}
        exact
      />
      <Route
        path={`${prefix1}/systemManage/backLog`}
        component={BacklogPage}
        exact
      />
      <Route
        path={`${prefix1}/systemManage/sensitiveLog`}
        component={SensitiveLogPage}
        exact
      />
      <Route
        path={`${prefix1}/systemManage/interfaceLog`}
        component={InterfaceLog}
        exact
      />
      <Route
        path={`${prefix1}/systemManage/operateLog`}
        component={OperateLogPage}
        exact
      />
      <Route
        path={`${prefix1}/systemMessage/messageBacklog`}
        component={BackLog}
        exact
      />
      <Route
        path={`${prefix1}/systemMessage/messageBacklog/approveDetail`}
        component={ApproveDetail}
        exact
      />
      <Route
        path={`${prefix1}/channelManager`}
        component={ChannelManager}
        exact
      />
      <Route
        path={`${prefix1}/channelManager/channelAdd`}
        component={ChannelAdd}
        exact
      />
      <Route
        path={`${prefix2}/channelManager/channelNumber`}
        component={ChannelNumber}
        exact
      />
      <Route
        path={`${prefix2}/channelManager/channelNumber/edit`}
        component={Edit}
        exact
      />
      <Route
        path={`${prefix2}/channelManager/channelList/channelRegister`}
        component={ChannelRegister}
        exact
      />
      <Route
        path={`${prefix2}/personalInfoMgt/userManagement`}
        component={UserManagement}
        exact
      />
      <Route
        path={`${prefix2}/channelManager/labelManager`}
        component={LabelManager}
        exact
      />
      <Route
        path={`${prefix2}/channelManager/labelManager/addLabel/:record?`}
        component={labelAdd}
        exact
      />
      <Route
        path={`${prefix2}/channelManager/labelManager/editLabel/:record?`}
        component={labelEdit}
        exact
      />
      <Route
        path={`${prefix2}/channelManager/labelManager/labelDetail/:labelId?`}
        component={LabelDetail}
        exact
      />
      <Route
        path={`${prefix2}/channelManager/myLabelManager`}
        component={MyLabelManager}
        exact
      />
      <Route
        path={`${prefix2}/channelManager/myLabelManager/myAddLabel/:record?`}
        component={MyLabelAdd}
        exact
      />
      <Route
        path={`${prefix2}/channelManager/myLabelManager/myEditLabel/:record?`}
        component={MyLabelEdit}
        exact
      />
      <Route
        path={`${prefix2}/channelManager/myLabelManager/myLabelDetail/:labelId?`}
        component={MyLabelDetail}
        exact
      />
      <Route
        path={`${prefix2}/SMSmanagement/SMSquotaList`}
        component={SMSquotaList}
        exact
      />
      <Route
        path={`${prefix2}/SMSmanagement/SMSquotaList/AddSMSquota`}
        component={AddSMSquota}
        exact
      />
      <Route
        path={`${prefix2}/SMSmanagement/SMSquotaList/historyRecord`}
        component={SMSquotaHistoryRecord}
        exact
      />
      <Route
        path={`${prefix2}/SMSmanagement/SMSstatistics`}
        component={SMSstatistics}
        exact
      />
      <Route
        path={`${prefix2}/templateManager`}
        component={TemplateManager}
        exact
      />
      <Route
        path={`${prefix2}/TemplateManager/add`}
        component={AddTemplate}
        exact
      />
      <Route
        path={`${prefix2}/AcceptGroup/list`}
        component={AcceptGroup}
        exact
      />
      <Route
        path={`${prefix2}/AcceptGroup/list/AcceptAdd`}
        component={AddAcceptGroup}
        exact
      />
      <Route
        path={`${prefix2}/channelManager/dingdingQun`}
        component={dingdingQunPage}
        exact
      />
      <Route
        path={`${prefix2}/messageManager/msgSourceManage`}
        component={MsgSourceManage}
        exact
      />
      <Route
        path={`${prefix2}/messageManager/msgSourceManage/msgSourceDetail`}
        component={MsgSourceDetail}
        exact
      />
      <Route
        path={`${prefix2}/messageManager/msgSourceManage/msgSourceLogs`}
        component={MsgSourceLogs}
        exact
      />
      <Route
        path={`${prefix2}/messageManager/tenantManage`}
        component={TenantPage}
        exact
      />
    </Switch>
  );

  render() {
    return (
      <Router>
        <BaseLayout>{this.renderRouter()}</BaseLayout>
      </Router>
    );
  }
}

function RouterFunc() {
  return <RouterConfig />;
}

export default RouterFunc;
